const { ipcRenderer } = require('electron');
const Store = require('electron-store');

const store = new Store();

document.addEventListener('DOMContentLoaded', () => {
    const emailInput = document.getElementById('email');
    const passwordInput = document.getElementById('password');
    const saveBtn = document.getElementById('save-btn');

    // 加载已保存的设置
    emailInput.value = store.get('email', '');
    passwordInput.value = store.get('password', '');

    saveBtn.addEventListener('click', () => {
        const email = emailInput.value;
        const password = passwordInput.value;

        if (email && password) {
            store.set('email', email);
            store.set('password', password);
            alert('设置已保存');
            ipcRenderer.send('settings-updated');
        } else {
            alert('请填写所有字段');
        }
    });
});